import dayjs from 'dayjs'

// 租赁周期限制最小时长 60 分钟
const timeRangeValidator = (rule, value, callback) => {
  if (value) {
    let start = value[0]
    let end = value[1]
    if (start && end) {
      let diff = dayjs(end).diff(dayjs(start))
      if (diff < 60 * 60 * 1000) {
        callback('租赁周期最小时间范围为1小时')
      }
    } else {
      callback('请选择预计租赁周期')
    }
  }
  callback()
}

export { timeRangeValidator }
